package com.hvtt.web.utilities;

import com.hvtt.web.connection.WEBConnection;
import com.hvtt.web.controller.Sys_NgonNguDetController;
import com.hvtt.web.models.Sys_ngonngu;
import com.hvtt.web.models.Sys_ngonngudet;
import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.internal.org.json.JSONArray;
import facebook4j.internal.org.json.JSONException;
import facebook4j.internal.org.json.JSONObject;
import java.io.IOException;
import java.io.Serializable;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.component.html.HtmlForm;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.view.facelets.FaceletContext;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.text.WordUtils;
import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailConstants;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.apache.commons.mail.SimpleEmail;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.fluent.Request;
import org.primefaces.component.behavior.ajax.AjaxBehavior;
import org.primefaces.component.behavior.ajax.AjaxBehaviorListenerImpl;
import org.primefaces.component.dialog.Dialog;
import org.primefaces.component.panel.Panel;
import org.primefaces.context.RequestContext;
import org.primefaces.event.CloseEvent;

public class Utilities implements Serializable {

    private static BigInteger data;

    public static String getSS_USER() {
        return "SS_USER_ACCOUNT";
    }

    public static String getSS_Language() {
        return "SS_LANGUAGE";
    }

    public static String getSS_Language_Data() {
        return "SS_LANGUAGE_DATA";
    }

    public static String getSS_Search_Data() {
        return "SS_Search_DATA";
    }

    public static String getSS_ListLanguage() {
        return "SS_LIST_LANGUAGE";
    }

    @SuppressWarnings("empty-statement")
    public static String GetPathUserUploadFile() {
        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
        return context.getRealPath(context.getInitParameter("com.hvtt.param.users.uploadFilePath"));
        //return context.getInitParameter(ConstClass.UPLOAD_FILE_PATH_USER);
    }

    public static String GetURLUserUploadFile() {
        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
        return context.getInitParameter(ConstClass.UPLOAD_FILE_URL_USER);
    }

    public static void setCurrentLanguage(String NgonNguID) {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        HttpSession httpSession = request.getSession(false);
        httpSession.setAttribute(Utilities.getSS_Language(), NgonNguID);
    }

    public static String getCurrentLanguage() {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        HttpSession httpSession = request.getSession(false);
        Object obj = httpSession.getAttribute(Utilities.getSS_Language());
        return (obj == null || "".equals(obj.toString().trim()) ? "EN" : obj.toString());
    }

    public static void setLanguageData() throws SQLException {
        Sys_NgonNguDetController c = new Sys_NgonNguDetController();

        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        HttpSession httpSession = request.getSession(false);
        httpSession.setAttribute(Utilities.getSS_Language_Data(), c.findAllNgonNguDet(getCurrentLanguage()));
    }

    /**
     * Encrypt data using MD5.
     *
     * @param str String will be encrypted.
     * @return String has been ecrypted.
     * @throws NoSuchAlgorithmException
     */
    @SuppressWarnings("CallToThreadDumpStack")
    public static String encrypt(String str) {
        try {
            byte[] chars = str.getBytes();
            MessageDigest m = MessageDigest.getInstance("MD5");
            m.update(chars, 0, chars.length);
            data = new BigInteger(1, m.digest());
        } catch (NoSuchAlgorithmException alg) {
            alg.printStackTrace();
        }
        return String.format("%1$032X", data);
    }

    /**
     * Delete file if file exists
     *
     * @author Nguyễn Hoàng Danh
     * @return true if delete success else false
     */
    public static boolean deleteFile(java.io.File source)
            throws java.io.IOException {
        if (source.exists()) {
            return source.delete();
        }
        return false;
    }

    public static String getCurrentTime() {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf1 = new SimpleDateFormat(
                ConstClass.DATE_FORMAT_NOW);
        return sdf1.format(cal.getTime());
    }

    /**
     * Get managed bean based on the bean name.
     *
     * @param beanName the bean name
     * @return the managed bean associated with the bean name
     */
    public static <T> T getManagedBean(Class<T> type) {
        FacesContext fc = FacesContext.getCurrentInstance();
        ELContext elc = fc.getELContext();
        ExpressionFactory ef = fc.getApplication().getExpressionFactory();
        ValueExpression ve = ef.createValueExpression(elc, getJsfEl(WordUtils.uncapitalize(type.getSimpleName())), type);
        T bean = (T) ve.getValue(elc);
        return bean;
    }

    public static HttpServletRequest getRequest() {
        FacesContext fc = FacesContext.getCurrentInstance();
        return (HttpServletRequest) fc.getExternalContext().getRequest();
    }
    public static HttpServletResponse getResponse() {
        FacesContext fc = FacesContext.getCurrentInstance();
        return (HttpServletResponse) fc.getExternalContext().getResponse();
    }
    public static ServletContext getServletContext(){
         FacesContext fc = FacesContext.getCurrentInstance();
        return (ServletContext) fc.getExternalContext().getContext();
    }
    /*
     * Redirect to a provided url.
     */

    public static void redirect(String url) {
        try {
            FacesContext fctx = FacesContext.getCurrentInstance();
            fctx.getExternalContext().redirect(url);
            fctx.responseComplete();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }

    private static String getJsfEl(String value) {
        return "#{" + value + "}";
    }

    public static String getRealPathRoot() {
        return FacesContext.getCurrentInstance().getExternalContext().getRealPath("/");
    }

    public static String getPathUploadFiles() {
        return FacesContext.getCurrentInstance().getExternalContext().getInitParameter(ConstClass.UPLOAD_FILE_PATH);
    }

    public static String getPathUploadFileTemps() {
        return FacesContext.getCurrentInstance().getExternalContext().getInitParameter(ConstClass.UPLOAD_FILE_TEMPS);
    }

    /**
     * @author Nguyễn Hoàng Danh
     * @param dateFormat
     *
     * String format from {'dd MMMMM yyyy' or yyyyMMdd or dd.MM.yy or MM/dd/yy
     * or yyyy.MM.dd G 'at' hh:mm:ss z or EEE, MMM d, ''yy or h:mm a or
     * H:mm:ss:SSS or K:mm a,z or yyyy.MMMMM.dd GGG hh:mm aaa or yyyy-MM-dd
     * HH:mm:ss.S or yyyy-MM-dd etc...}
     *
     * @return String dateTime
     */
    public static String getCurrentTimeFormat(String dateFormat) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf1 = new SimpleDateFormat(dateFormat);
        return sdf1.format(cal.getTime());
    }

    /**
     * @author Nguyễn Hoàng Danh
     * @param dateFormat
     *
     * String format from {'dd MMMMM yyyy' or yyyyMMdd or dd.MM.yy or MM/dd/yy
     * or yyyy.MM.dd G 'at' hh:mm:ss z or EEE, MMM d, ''yy or h:mm a or
     * H:mm:ss:SSS or K:mm a,z or yyyy.MMMMM.dd GGG hh:mm aaa or yyyy-MM-dd
     * HH:mm:ss.S or yyyy-MM-dd etc...}
     *
     * @return String dateTime
     */
    public static String parseDateTime(Date date, String dateFormat) {
        SimpleDateFormat sdf1 = new SimpleDateFormat(dateFormat);
        return sdf1.format(date);
    }

    public static String generateFileNameUpload(String fileName) {
        return getCurrentTimeFormat("yyyy-MM-dd") + "-" + System.currentTimeMillis() + "-" + fileName;
    }

    public static String getLanguages(String key) throws SQLException {
        /* LanguagesdefController languagesdefController = getManagedBean(LanguagesdefController.class);
         if (languagesdefController.getLanguagesdefLazy() == null
         || languagesdefController.isReloadable()
         || !FacesContext.getCurrentInstance().isPostback()) {
         languagesdefController.initialize();
         }
         Languages curent = getManagedBean(LanguagesController.class).getCurrentLanguages();
         List<Languagesdef> lst = (List<Languagesdef>) languagesdefController.getLanguagesdefLazy().getWrappedData();
         int index = lst.indexOf(new Languagesdef(key.toUpperCase(), curent.getLanguagesID()));
         if (index != -1) {
         return lst.get(index).getContent();
         } else {
         return key;
         }
         * */
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        HttpSession httpSession = request.getSession(false);
        List<Sys_ngonngudet> lst = (List<Sys_ngonngudet>) httpSession.getAttribute(Utilities.getSS_Language_Data());
        if (lst == null) {
            setCurrentLanguage("EN");
            setLanguageData();

            lst = (List<Sys_ngonngudet>) httpSession.getAttribute(Utilities.getSS_Language_Data());
        }

        for (Sys_ngonngudet obj : lst) {
            if (obj.getDinhNghia().trim().toUpperCase() == null ? key.trim().toUpperCase() == null : obj.getDinhNghia().trim().toUpperCase().equals(key.trim().toUpperCase())) {
                return obj.getNoiDung();
            }
        }
        return key;
    }

    public static String getMessageErrorFromCode(int code) {
        switch (code) {
            case 11000:
                return "Duplicate key error";
            case 11001:
                return "Duplicate key on update";
        }
        return "";
    }

    public static Dialog openDialog(String title, boolean modal, String widgetID, String componentParentID, String pageContent, String commandCloseDialog) {
        Dialog dialog = new Dialog();
        dialog.setStyleClass("fixCssDialog");
        dialog.setHeader(title);
        dialog.setModal(modal);
        dialog.setWidgetVar(widgetID);
        dialog.setDraggable(true);
        dialog.setShowEffect("clip");
        dialog.setHideEffect("clip");
        dialog.setPosition("center");
        dialog.setDynamic(false);
        dialog.setMaximizable(true);
        dialog.setResizable(true);
        dialog.setId(widgetID + "ID");

        Panel panel = new Panel();
        panel.setStyleClass("dialogContent");
        FacesContext facesContext = FacesContext.getCurrentInstance();
        FaceletContext f2ctx = (FaceletContext) facesContext.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
        try {
            f2ctx.includeFacelet(panel, pageContent);
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        AjaxBehavior ajaxBehavior = new AjaxBehavior();//myAjax


        FacesContext context = FacesContext.getCurrentInstance();
        MethodExpression actionListener = context.getApplication().getExpressionFactory()
                .createMethodExpression(context.getELContext(), getJsfEl(commandCloseDialog), void.class, new Class[]{CloseEvent.class});

        ajaxBehavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(actionListener, actionListener));
        ajaxBehavior.setListener(actionListener);

        dialog.addClientBehavior("close", ajaxBehavior);
        dialog.getChildren().add(panel);
        FacesContext.getCurrentInstance().getViewRoot().findComponent(componentParentID).getChildren().add(dialog);
        RequestContext.getCurrentInstance().update(componentParentID);
        return dialog;
    }

    public static Dialog createDialog(String title, boolean modal, String widgetID, String componentParentID, String pageContent, String jsfEl) {
        Dialog dialog = new Dialog();
        dialog.setStyleClass("fixCssDialog");
        dialog.setHeader(title);
        dialog.setModal(modal);
        dialog.setWidgetVar(widgetID);
        dialog.setDraggable(true);
        dialog.setShowEffect("scale");
        dialog.setHideEffect("scale");
        dialog.setPosition("center");
        dialog.setDynamic(false);
        dialog.setMaximizable(true);
        dialog.setResizable(true);
        dialog.setId(widgetID + "ID");
//        UIForm uIForm=new UIForm();
        HtmlForm form = new HtmlForm();
        Panel panel = new Panel();
        panel.setStyleClass("dialogContent");
        FacesContext facesContext = FacesContext.getCurrentInstance();
        FaceletContext f2ctx = (FaceletContext) facesContext.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
        try {
            f2ctx.includeFacelet(panel, pageContent);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        form.getChildren().add(panel);

        AjaxBehavior ajaxBehavior = new AjaxBehavior();//myAjax


        FacesContext context = FacesContext.getCurrentInstance();
        MethodExpression actionListener = context.getApplication().getExpressionFactory()
                .createMethodExpression(context.getELContext(), getJsfEl(jsfEl), void.class, new Class[]{CloseEvent.class});

        ajaxBehavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(actionListener, actionListener));
        ajaxBehavior.setListener(actionListener);

        dialog.addClientBehavior("close", ajaxBehavior);
        dialog.getChildren().add(form);
//        dialog.setAppendToBody(true);
        FacesContext.getCurrentInstance().getViewRoot().findComponent(componentParentID).getChildren().add(dialog);
        RequestContext.getCurrentInstance().update(componentParentID);
        return dialog;
//        String showDialog = widgetID + ".show();";
//        RequestContext.getCurrentInstance().execute(showDialog);
    }

    public static Dialog createDialog1(String title, boolean modal, String widgetID, String componentParentID, String pageContent, String jsfEl) {
        Dialog dialog = new Dialog();
        dialog.setStyleClass("fixCssDialog");
        dialog.setHeader(title);
        dialog.setModal(modal);
        dialog.setWidgetVar(widgetID);
        dialog.setDraggable(true);
        dialog.setShowEffect("clip");
        dialog.setHideEffect("clip");
        dialog.setPosition("center");
        dialog.setDynamic(false);
        dialog.setMaximizable(true);
        dialog.setResizable(true);
        dialog.setId(widgetID + "ID");
        Panel panel = new Panel();
        panel.setStyleClass("dialogContent");
        FacesContext facesContext = FacesContext.getCurrentInstance();
        FaceletContext f2ctx = (FaceletContext) facesContext.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
        try {
            f2ctx.includeFacelet(panel, pageContent);
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        AjaxBehavior ajaxBehavior = new AjaxBehavior();//myAjax


        FacesContext context = FacesContext.getCurrentInstance();
        MethodExpression actionListener = context.getApplication().getExpressionFactory()
                .createMethodExpression(context.getELContext(), getJsfEl(jsfEl), void.class, new Class[]{CloseEvent.class});

        ajaxBehavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(actionListener, actionListener));
        ajaxBehavior.setListener(actionListener);

        dialog.addClientBehavior("close", ajaxBehavior);
        dialog.getChildren().add(panel);
        dialog.setAppendToBody(true);
        FacesContext.getCurrentInstance().getViewRoot().findComponent(componentParentID).getChildren().add(dialog);
        RequestContext.getCurrentInstance().update(componentParentID);
        return dialog;
//        String showDialog = widgetID + ".show();";
//        RequestContext.getCurrentInstance().execute(showDialog);
    }

    public static void fixSizeContent(String tableID) {
        StringBuilder builder = new StringBuilder("changeSizeContentUI('");
        builder.append(ConstClass.UIID.COMPONENT_ROOT_FORM_ID).append("','")
                .append(tableID).append("')");
        RequestContext.getCurrentInstance().execute(builder.toString());
    }

    /**
     * Format number to String.
     *
     * @param pattern la ###,###.### or ###.## or 000000.000 or $###,###.###
     * @param value
     * @see http://docs.oracle.com/javase/tutorial/java/data/numberformat.html
     * @return
     */
    public static String formatNumber(String pattern, double value) {
        DecimalFormat formatter = new DecimalFormat(pattern);
        String output = formatter.format(value);
        return output;
    }

    public static void send(String smtpServer, String to, String from,
            String psw, String subject, String body) throws Exception {
        // Code provide by congdongjava.com
        Properties props = System.getProperties();
        props.put("mail.smtp.host", smtpServer);
        props.put("mail.smtp.port", "25");
        props.put("mail.smtp.starttls.enable", "true");
        final String login = from;
        final String pwd = psw;
        Authenticator pa = null;
        if (login != null && pwd != null) {
            props.put("mail.smtp.auth", "true");
            pa = new Authenticator() {
                @Override
                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(login, pwd);
                }
            };
        }// else: no authentication
        Session session = Session.getInstance(props, pa);
        // — Create a new message –
        MimeMessage msg = new MimeMessage(session);
        // msg.setContent(body, "text/html; charset=UTF-8");
        // — Set the FROM and TO fields –
        msg.setFrom(new InternetAddress(from));
        msg.setRecipients(Message.RecipientType.TO,
                InternetAddress.parse(to, false));

        // — Set the subject and body text –
        msg.setSubject(subject);
        msg.setText(body, "utf-8", "html");// Để gởi nội dung dạng utf-8 các bạn
        // dùng msg.setContent(body,
        // "text/html; charset=UTF-8");
        // — Set some other header information –
        msg.setHeader("X-Mailer", "HVTTGROUP");
        msg.setSentDate(new Date());
        msg.saveChanges();
        // — Send the message –
        Transport.send(msg);
        System.out.println("Mail da duoc gui");

    }

    public static boolean sendMailPlainText(String hostFrom, String userSender, String passSender, String emailRecipient,
            String subject, String message) {//"smtp.googlemail.com"
        try {
            Email email = new SimpleEmail();
            email.setHostName(hostFrom);

            email.setSSLOnConnect(true);
            email.setSSLCheckServerIdentity(true);
            email.setSmtpPort(587);
            email.setStartTLSEnabled(true);
            email.setSslSmtpPort("465");

            email.setAuthenticator(new DefaultAuthenticator(userSender, passSender));

            email.setFrom(userSender);
            email.setSubject(subject);
            email.setMsg(message);
            email.addTo(emailRecipient);
            email.send();
            return true;
        } catch (EmailException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }

    public static boolean sendMailHtml(String hostFrom, String userSender, String passSender, String emailRecipient,
            String subject, String message) {//"smtp.googlemail.com"
        try {
            HtmlEmail email = new HtmlEmail();
            email.setHostName(hostFrom);

            email.setSSLOnConnect(true);
            email.setSSLCheckServerIdentity(true);
            email.setSmtpPort(587);
            email.setStartTLSEnabled(true);
            email.setSslSmtpPort("465");

            email.setAuthenticator(new DefaultAuthenticator(userSender, passSender));

            email.setFrom(userSender);
            email.setSubject(subject);
            email.setHtmlMsg(message);
            email.addTo(emailRecipient);
            email.send();
            return true;
        } catch (EmailException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }

    public static boolean sendMail(String hostFrom, String userSender, String passSender, String emailRecipient,
            String subject, String message, ConstClass.Email emailMessageType) {
        switch (emailMessageType) {
            case HTML_MESSAGE:
                return sendMailHtml(hostFrom, userSender, passSender, emailRecipient, subject, message);
            case PLAIN_TEXT:
                return sendMailPlainText(hostFrom, userSender, passSender, emailRecipient, subject, message);
            default:
                return false;
        }

    }

    public static void facebookLogin() {
    }

    public static String getResult(String url) {
        try {
            return Request.Get(url).addHeader("Accept-Charset", "utf-8")
                    .execute().returnContent().asString();
        } catch (ClientProtocolException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public static List<Sys_ngonngu> getListNgonNgu() throws SQLException {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        HttpSession httpSession = request.getSession(false);
        List<Sys_ngonngu> lst = (List<Sys_ngonngu>) httpSession.getAttribute(Utilities.getSS_ListLanguage());
        if (lst == null) {
            WEBConnection DAL = new WEBConnection();
            lst = DAL.executeQuery("select*from Sys_NgonNgu", Sys_ngonngu.class);

            httpSession.setAttribute(Utilities.getSS_ListLanguage(), lst);
        }
        return lst;
    }

    public static boolean sendMail(String to, String Subject, String Content) {
        try {
            HtmlEmail email = new HtmlEmail();
            email.setCharset(EmailConstants.UTF_8);
            email.setHostName(getPropertiesKey("com.hvtt.param.smtp.server"));

            email.setSSLOnConnect(Boolean.parseBoolean(getPropertiesKey("com.hvtt.param.smtp.ssl")));
            email.setSSLCheckServerIdentity(Boolean.parseBoolean(getPropertiesKey("com.hvtt.param.smtp.sslCheckServerIdentity")));
            email.setSmtpPort(Integer.parseInt(getPropertiesKey("com.hvtt.param.smtp.port")));
            email.setStartTLSEnabled(true);
            email.setSslSmtpPort(getPropertiesKey("com.hvtt.param.smtp.sslSmtpPort"));

            email.setAuthenticator(new DefaultAuthenticator(getPropertiesKey("com.hvtt.param.smtp.username"), getPropertiesKey("com.hvtt.param.smtp.password")));

            email.setFrom(getPropertiesKey("com.hvtt.param.smtp.username"));
            email.setSubject(Subject);
            email.setHtmlMsg(Content);
            email.addTo(to);
            email.send();
            return true;
        } catch (EmailException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }

    public static String getPropertiesKey(String key) {
        ResourceBundle bundle = ResourceBundleUtils.getBundle("com.hvtt.web.config.emailConfig");
        return bundle.getString(key);
    }

    public static String getFullDomainName() {
        StringBuilder builder = new StringBuilder();
        HttpServletRequest request = getRequest();
        if (request.getServerPort() != 80) {
            return builder.append(request.getScheme()).append("://")
                    .append(request.getServerName()).append(":")
                    .append(request.getServerPort()).toString();
        }
        return builder.append(request.getScheme()).append("://")
                .append(request.getServerName()).toString();
    }

    public static void main(String[] args) {
//        Utilities.sendMail("smtp.googlemail.com", "nguyenhoangdanh1987@gmail.com", "nguyenhoangdanh",
//                "htthonguyen@yahoo.com.vn", "Gui mail test chuong trinh", "<p style='color:red'>Danh gui mail html</p>", ConstClass.Email.HTML_MESSAGE);
//        Utilities.sendMail("smtp.mail.yahoo.com", "thuyhang_hvtt@yahoo.com.vn", "Thanhhang762119",
//                "danhnh2015@gmail.com", "Gui mail test chuong trinh", "<p style='color:red'>Danh gui mail html</p>", ConstClass.Email.HTML_MESSAGE);

        System.out.println(Math.tan((double) ('s' / 10 * 87)));
        //Utilities.facebookLogin();
    }
}
